package practice_0524;

import java.util.Random;
import java.util.Scanner;

public class practice06 {
    public static void main(String[] args) {
        char[] answer = new char[]{'B', 'A', 'D', 'C', 'C', 'B', 'C', 'A', 'D', 'B'};
        char[][] stu_ans = new char[8][answer.length];
        Random random = new Random();
        char tmp;
        for (int i = 0; i < stu_ans.length; i++) {
            for (int j = 0; j < stu_ans[0].length; j++) {
                tmp = (char) (random.nextInt(4) + 65);
                stu_ans[i][j] = tmp;
            }
        }
//        for (int i = 0; i <stu_ans.length ; i++) {
//            for (int j = 0; j < stu_ans[0].length; j++) {
//                System.out.print(stu_ans[i][j] +" ");
//            }
//            System.out.println();
//        }
        boolean if_conti = true;
        while (if_conti) {
            System.out.println("您想调去第几位学生的答题结果（有效数字为1~" + stu_ans.length + ")");
            Scanner scanner = new Scanner(System.in);
            int stu_num = scanner.nextInt();
            System.out.println("第" + stu_num + "位同学的全部答案为:");
            for (int i = 0; i < stu_ans[0].length; i++) {
                System.out.print(stu_ans[stu_num - 1][i] + " ");
            }
            int right_num = 0;
            System.out.println();
            for (int i = 0; i < answer.length; i++) {
                if (stu_ans[stu_num - 1][i] == answer[i]) {
                    right_num++;
                }
            }
            System.out.println("第" + stu_num + "位同学一共答对了" + right_num + "道题");
            while(true){
                System.out.println("是否继续查询(1，继续查询 2，退出系统)");
                int flag = scanner.nextInt();
                if(flag == 2){
                    System.out.println("本次查询已结束，欢迎下次再来！");
                    if_conti = false;
                    break;
                }
                if(flag != 1){
                    System.out.println("输入错误，请重新输入!");
                }
                if(flag == 1){
                    break;
                }

            }
        }
    }
}
